package 线程课后习题;

class ClimThread extends Thread {
	private int time;//时间
	private int km;
	
	public ClimThread(String name, int time, int km) {
		super(name);
		this.time = time;
		this.km = km * 1000 / 100;
	}
	
	@Override
	public void run() {
		while (km > 0) {
			try {
				Thread.sleep(this.time);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			km--;
			System.out.println(Thread.currentThread().getName() + "爬完100米");
		}
		System.out.println(Thread.currentThread().getName() + "到达终点！");
	}
}

public class Test3 {
	public static void main(String[] args) {
		ClimThread old = new ClimThread("老人", 100, 10);
		ClimThread yong = new ClimThread("年轻人", 200, 8);
		old.start();
		yong.start();
		
	}
}
